package dbcontrol

import (
	"MqttCloudProtocolServer/publiclib/datamodel/dborm"
)

//ProtocolenumControl struct
type ProtocolenumControl struct {
	base dbOperabase
	Data *dborm.Protocolenum
}

//CreateProtocolenumControl 初始化几种指针函数
func CreateProtocolenumControl() *ProtocolenumControl {
	content := new(ProtocolenumControl)
	content.base.GetData = func() interface{} {
		return content.Data
	}
	content.base.SetData = func(data interface{}) {
		if data != nil {
			content.Data = data.(*dborm.Protocolenum)
		}
	}
	content.base.GetKey = func() interface{} {
		if content.Data == nil {
			return nil
		}
		return content.Data.ID
	}
	content.base.CreateNew = func() interface{} {
		res := new(dborm.Protocolenum)
		res.ID = 0
		return res
	}
	content.base.CreateNil = func() interface{} {
		return new(dborm.Protocolenum)
	}
	return content
}

//GetAll 获取全部用户-服务器映射信息
func (_this *ProtocolenumControl) GetAll() ([]*dborm.Protocolenum, error) {
	res := make([]*dborm.Protocolenum, 0)
	_, err := _this.base.GetAllByPage(&res, 0, 0, 0)
	return res, err
}

//FindByID 根据主键获取一条记录
func (_this *ProtocolenumControl) FindByID(id int) error {
	return _this.base.FindByID(id)
}
